/*************************************************
 * 
 * Copyright by Bruno Eberhard
 * 
 * Created on 12.06.2006
 *
 *************************************************/
package fightplan.business;

import java.beans.PropertyChangeListener;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public abstract class AbstractFighter implements FighterProvider, Comparable<AbstractFighter>, Serializable {
	private Dojo dojo;

	protected AbstractFighter() {
	}

	// FighterProvider

	public AbstractFighter getFighter() {
		return this;
	}

	public void addPropertyChangeListener(PropertyChangeListener listener) {
		// do nothing, we never change
	}

	public void removePropertyChangeListener(PropertyChangeListener listener) {
		// do nothing
	}

	// get / set

	public Dojo getDojo() {
		return dojo;
	}

	public void setDojo(Dojo dojo) {
		this.dojo = dojo;
	}

	public List<Category> searchCategories(Tournament tournament) {
		List<Category> allCategories = tournament.getCategories();
		List<Category> myCategories = new ArrayList<Category>();
		for (Category category : allCategories) {
			if (category.getFighters().contains(this)) {
				myCategories.add(category);
			}
		}
		return myCategories;
	}

	public abstract String getCategoryNames(Tournament tournament);

	public abstract String getName();

	public abstract String getDisplayName();

	//

	public int compareTo(AbstractFighter f) {
		return getName().compareTo(f.getName());
	}

}